package com.smedi.ismedi.inmail.api.feign;

import com.smedi.ismedi.inmail.api.dto.request.*;
import com.smedi.ismedi.inmail.api.dto.response.AnnouncementResponse;
import com.smedi.ismedi.inmail.api.dto.response.FileResponse;
import com.smedi.ismedi.inmail.api.dto.response.NodeResponse;
import com.smedi.ismedi.inmail.api.dto.response.ReadRecordResponse;
import com.smedi.ismedi.web.starter.common.PaginationData;
import com.smedi.ismedi.web.starter.common.ResponseData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;
import java.util.List;

/**
 * 发布通知公告FeignApi
 *
 * @author jiangqinxuan
 * @date 2021/07/26
 */
@FeignClient(name = "ismedi-inmail")
@Api(value = "通知公告", tags = {"通知公告"})
@RequestMapping(value = "/api/v1/announcement")
public interface RemoteAnnouncementFeignApi {

    /**
     * 新建通知公告
     *
     * @param announcementCreateRequest 通知公告新建请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "新建通知公告")
    @PostMapping(value = "/create")
    ResponseData<AnnouncementResponse> createAnnouncement(@Validated @RequestBody AnnouncementCreateRequest announcementCreateRequest);

    /**
     * 编辑通知公告
     *
     * @param announcementEditRequest 通知公告编辑请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "编辑通知公告")
    @PostMapping(value = "/edit")
    ResponseData<AnnouncementResponse> editAnnouncement(@Validated @RequestBody AnnouncementEditRequest announcementEditRequest);

    /**
     * 审核通知公告
     *
     * @param announcementReviewRequest 通知公告审核请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "审核通知公告")
    @PostMapping(value = "/review")
    ResponseData<AnnouncementResponse> reviewAnnouncement(@Validated @RequestBody AnnouncementReviewRequest announcementReviewRequest);

    /**
     * 失效通知公告
     *
     * @param announcementDisableRequest 通知公告失效请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "失效通知公告")
    @PostMapping(value = "/disable")
    ResponseData<AnnouncementResponse> disableAnnouncement(@Validated @RequestBody AnnouncementDisableRequest announcementDisableRequest);

    /**
     * 压缩包下载
     *
     * @param attachmentKeyList 附件key
     * @return ResponseEntity<byte [ ]>
     */
    @ApiOperation(httpMethod = "POST", value = "压缩包下载")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "attachmentKeyList", value = "附件key", dataType = "List<String>"),
    })
    @PostMapping(value = "/download")
    ResponseEntity<byte[]> postDownloadFilesToZip(@RequestBody List<String> attachmentKeyList) throws IOException;

    /**
     * 指定参数下载附件压缩包
     *
     * @param downloadFileToZipRequest 导出参数
     * @return ResponseEntity<FileSystemResource>
     */
    @ApiOperation(httpMethod = "POST", value = "指定参数下载附件压缩包")
    @PostMapping(value = "/downloadByParams")
    ResponseData<FileResponse> postDownloadFilesSetNameToZip(@Validated @RequestBody DownloadFileToZipRequest downloadFileToZipRequest) throws IOException;


    /**
     * 获取 通知公告 单一（详情）
     *
     * @param announcementOneQueryRequest 通知公告单一查询
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "获取 通知公告 单一（详情）")
    @PostMapping(value = "/one")
    ResponseData<AnnouncementResponse> getAnnouncementOne(@Validated @RequestBody AnnouncementOneQueryRequest announcementOneQueryRequest);

    /**
     * 获取 通知公告 列表
     *
     * @param announcementListQueryRequest 通知公告列表查询
     * @return ResponseData<List < AnnouncementResponse>>
     */
    @ApiOperation(httpMethod = "POST", value = "获取 通知公告 列表")
    @PostMapping(value = "/list")
    ResponseData<List<AnnouncementResponse>> getAnnouncementList(@Validated @RequestBody AnnouncementListQueryRequest announcementListQueryRequest);

    /**
     * 获取 通知公告 列表（通知公告管理）
     *
     * @param announcementPageQueryRequest 通知公告列表查询
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "获取 通知公告 分页（通知公告管理）")
    @PostMapping(value = "/page/management")
    ResponseData<PaginationData<AnnouncementResponse>> getAnnouncementPageInManagement(@Validated @RequestBody AnnouncementPageQueryRequest announcementPageQueryRequest);

    /**
     * 获取 通知公告 列表（个人通知公告）
     *
     * @param announcementPageQueryRequest 通知公告列表查询
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "获取 通知公告 分页（个人通知公告）")
    @PostMapping(value = "/page/person")
    ResponseData<PaginationData<AnnouncementResponse>> getAnnouncementPageInPerson(@Validated @RequestBody AnnouncementPageQueryRequest announcementPageQueryRequest);

    /**
     * 获取 通知公告 列表（手机端）
     *
     * @param announcementPageQueryRequest 通知公告列表查询
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "获取 通知公告 分页（手机端）")
    @PostMapping(value = "/page")
    ResponseData<PaginationData<AnnouncementResponse>> getAnnouncementPage(@Validated @RequestBody AnnouncementPageQueryRequest announcementPageQueryRequest);

    /**
     * 获取 组织树
     *
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "GET", value = "获取 组织树")
    @GetMapping(value = "/getOrganizationTree")
    ResponseData<NodeResponse> getOrganizationTree();

    /**
     * 获取 项目树
     *
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "GET", value = "获取 项目树")
    @GetMapping(value = "/getProjectTree")
    ResponseData<NodeResponse> getProjectTree();

    /**
     * 更新 流转单
     *
     * @param announcementReadRecordRequest 流转单 更新 命令
     * @return ResponseEntity<byte [ ]>
     */
    @ApiOperation(httpMethod = "POST", value = "更新 流转单")
    @PostMapping(value = "/read-record/update")
    ResponseData<Boolean> updateReadRecord(@Validated @RequestBody AnnouncementReadRecordRequest announcementReadRecordRequest) throws IOException;

    /**
     * 当前登录人是否有权限新增通知公告（临时接口）
     *
     * @return ResponseEntity<Boolean>
     */
    @ApiOperation(httpMethod = "GET", value = "当前登录人是否有权限新增通知公告（临时接口）")
    @GetMapping(value = "/getAccessToIncrease")
    ResponseData<Boolean> getAccessToIncrease();

    /**
     * 删除通知公告
     *
     * @param announcementRemoveRequest 通知公告删除请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "删除通知公告")
    @PostMapping(value = "/remove")
    ResponseData<Boolean> removeAnnouncement(@Validated @RequestBody AnnouncementRemoveRequest announcementRemoveRequest);

    /**
     * 获取 流转单 单一
     *
     * @param readRecordOneQueryRequest 流转单 获取 单一 请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "获取 流转单 单一")
    @PostMapping(value = "/read-record/one")
    ResponseData<String> getReadRecordOne(@Validated @RequestBody ReadRecordOneQueryRequest readRecordOneQueryRequest) throws IOException;

    /**
     * 下载 流转单 单一
     *
     * @param readRecordOneQueryRequest 流转单 获取 单一 请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "下载 流转单 单一")
    @PostMapping(value = "/read-record/download")
    ResponseData<String> downloadReadRecordOne(@Validated @RequestBody ReadRecordOneQueryRequest readRecordOneQueryRequest) throws IOException;

    /**
     * 获取 流转单 全部（压缩包）
     *
     * @param readRecordAllZipRequest 流转单 获取 单一 请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "获取 流转单 全部（压缩包）")
    @PostMapping(value = "/read-record/all/zip")
    ResponseData<ReadRecordResponse> getAllReadRecordZip(@Validated @RequestBody ReadRecordAllZipRequest readRecordAllZipRequest);

    /**
     * 导出 通知公告
     *
     * @param announcementExportRequest 通知公告 导出 请求
     * @return ResponseData<AnnouncementResponse>
     */
    @ApiOperation(httpMethod = "POST", value = "导出 通知公告")
    @PostMapping(value = "/announcement/export")
    ResponseData<String> exportAnnouncement(@Validated @RequestBody AnnouncementExportRequest announcementExportRequest);
}
